// the compiled Rs-DeltaS relation - forced to use Tos's data :(
// created: Nov 30, 2023 by Yazhou SUN
// lasted modified: Dec 4, 2023

double Rs(double rs, bool opt);
double DS(double ds, bool opt);

void rsdsCmpHFCp_Tos1(){
  const int n = 2;
  double xh[n] = {-30., 30.}, yh[n] = {1.23, 0.4};
  TGraph *gHatch = new TGraph(2, xh, yh);
  gHatch->SetLineColor(kWhite);
  gHatch->SetLineWidth(-3200);
  gHatch->SetFillStyle(3004);
  gHatch->SetFillColor(1);
  gHatch->SetMinimum(0.15); gHatch->SetMaximum(1.3);
  gHatch->SetTitle("");
  TAxis *ax = gHatch->GetXaxis(), *ay = gHatch->GetYaxis();
  ax->SetRangeUser(-30, 24);
  ax->SetTitle("\\DeltaS (MeV)"); ay->SetTitle("R_{s}= \\sigma_{exp}/\\sigma_{th}");
  ax->SetTitleOffset(1.0);

  ax->SetLabelSize(0.05); ax->SetTitleSize(0.05);
  ay->SetLabelSize(0.05); ay->SetTitleSize(0.05);
  ax->SetTitleOffset(0.85); ay->SetTitleOffset(0.95);
  ax->CenterTitle(); ay->CenterTitle();
  gStyle->SetEndErrorSize(9);

  static const double DDS = 2.; // to place apart the dots
  static const double MS = 1.5; // marker size
  static const double LW = 2.; // line width
  // r0 = HF //
  // my result: HF from XYP(SKX), Horiuchi + YSOX-SM //
  TGraphErrors *gAysox = new TGraphErrors();
  gAysox->SetPoint(0, -1.860418, 0.504520); gAysox->SetPointError(0, 0., 0.043555); // C12
  gAysox->SetPoint(1, 13.278856, 0.411255); gAysox->SetPointError(1, 0., 0.062135); // C13
  gAysox->SetPoint(2, 12.811471-DDS, 0.441417); gAysox->SetPointError(2, 0., 0.029215); // C14
  gAysox->SetPoint(3, 20.159450, 0.419910); gAysox->SetPointError(3, 0., 0.041237); // C15
  gAysox->SetPoint(4, 18.302800, 0.303909); gAysox->SetPointError(4, 0., 0.033212); // C16
  gAysox->SetMarkerStyle(24); gAysox->SetMarkerSize(MS);
  gAysox->SetMarkerColor(kCyan); gAysox->SetLineColor(kCyan);
  gAysox->SetLineWidth(LW);
  // my result: HF from XYP(SKX), Horiuchi + WBP-SM //
  TGraphErrors *gAwbp = new TGraphErrors();
  gAwbp->SetPoint(0, -2.077582, 0.508106); gAwbp->SetPointError(0, 0., 0.043865); // C12
  gAwbp->SetPoint(1, 13.309388, 0.420019); gAwbp->SetPointError(1, 0., 0.063459); // C13
  gAwbp->SetPoint(2, 12.863256-DDS, 0.425768); gAwbp->SetPointError(2, 0., 0.028180); // C14
  gAwbp->SetPoint(3, 20.136069, 0.431410); gAwbp->SetPointError(3, 0., 0.042367); // C15
  gAwbp->SetPoint(4, 18.302800, 0.290462); gAwbp->SetPointError(4, 0., 0.031742); // C16
  gAwbp->SetMarkerStyle(21); gAwbp->SetMarkerSize(MS);
  gAwbp->SetMarkerColor(kRed); gAwbp->SetLineColor(kRed);
  gAwbp->SetLineWidth(LW);
  // Tos's result: HF from Tos(sigma_sp) + WBP-SM //
  TGraphErrors *gTwbp = new TGraphErrors();
  gTwbp->SetPoint(0, -2.193269, 0.705743); gTwbp->SetPointError(0, 0., 0.060927); // C12
  gTwbp->SetPoint(1, 13.281650, 0.548734); gTwbp->SetPointError(1, 0., 0.082906); // C13
  gTwbp->SetPoint(2, 12.817810-DDS, 0.565227); gTwbp->SetPointError(2, 0., 0.037410); // C14
  gTwbp->SetPoint(3, 20.134090, 0.560112); gTwbp->SetPointError(3, 0., 0.055006); // C15
  gTwbp->SetPoint(4, 18.302800, 0.342755); gTwbp->SetPointError(4, 0., 0.037457); // C16
  gTwbp->SetMarkerStyle(22); gTwbp->SetMarkerSize(MS);
  gTwbp->SetMarkerColor(kRed); gTwbp->SetLineColor(kRed);
  gTwbp->SetLineWidth(1); // gTwbp->SetLineStyle(7);
  // Tos's result: HF from Tos(sigma_sp) + NCSM //
  TGraphErrors *gTnc = new TGraphErrors();
  gTnc->SetPoint(0, -2.300814, 0.765318); gTnc->SetPointError(0, 0., 0.066070); // C12
  gTnc->SetPoint(1, 13.253910, 0.574639); gTnc->SetPointError(1, 0., 0.086820); // C13
  gTnc->SetPoint(2, 12.763328-DDS, 0.611187); gTnc->SetPointError(2, 0., 0.040452); // C14
  gTnc->SetPoint(3, 20.138367, 0.586619); gTnc->SetPointError(3, 0., 0.057609); // C15
  gTnc->SetPoint(4, 18.302800, 0.430804); gTnc->SetPointError(4, 0., 0.047079); // C16
  gTnc->SetMarkerStyle(21); gTnc->SetMarkerSize(1);
  gTnc->SetMarkerColor(kBlue); gTnc->SetLineColor(kBlue);
  gTnc->SetLineWidth(1); // gTnc->SetLineStyle(7);
  // Tos's result: HF from Tos(sigma_sp) + GSM //
  TGraphErrors *gTg = new TGraphErrors();
  gTg->SetPoint(0, -2.200049, 0.673720); gTg->SetPointError(0, 0., 0.058162); // C12
  gTg->SetPoint(1, 13.213826, 0.575316); gTg->SetPointError(1, 0., 0.086922); // C13
  gTg->SetPoint(2, 12.881171-DDS, 0.647298); gTg->SetPointError(2, 0., 0.042842); // C14
  gTg->SetPoint(3, 20.105215, 0.534767); gTg->SetPointError(3, 0., 0.052517); // C15
  gTg->SetPoint(4, 18.302800, 0.405799); gTg->SetPointError(4, 0., 0.044346); // C16
  gTg->SetMarkerStyle(20); gTg->SetMarkerSize(1);
  gTg->SetMarkerColor(kBlack); gTg->SetLineColor(kBlack);
  gTg->SetLineWidth(1); // gTg->SetLineStyle(7);
  // my result: HF from XYP(SKX), Horiuchi + NCSM //
  TGraphErrors *gAnc = new TGraphErrors();
  gAnc->SetPoint(0, -2.193067, 0.554845); gAnc->SetPointError(0, 0., 0.047900); // C12
  gAnc->SetPoint(2, 12.794200-DDS, 0.462364); gAnc->SetPointError(2, 0., 0.030602); // C14
  gAnc->SetPoint(1, 13.277898, 0.441435); gAnc->SetPointError(1, 0., 0.066695); // C13
  gAnc->SetPoint(3, 20.140354, 0.451790); gAnc->SetPointError(3, 0., 0.044368); // C15
  gAnc->SetPoint(4, 18.302800, 0.365077); gAnc->SetPointError(4, 0., 0.039896); // C16
  gAnc->SetMarkerStyle(23); gAnc->SetMarkerSize(2.);
  gAnc->SetMarkerColor(8); gAnc->SetLineColor(8);
  gAnc->SetLineWidth(LW);
  // my result: HF from XYP(SKX), Horiuchi + GSM //
  TGraphErrors *gAg = new TGraphErrors();
  gAg->SetPoint(0, -2.125606, 0.504146); gAg->SetPointError(0, 0., 0.043523); // C12
  gAg->SetPoint(2, 12.942826-DDS, 0.485178); gAg->SetPointError(2, 0., 0.032112); // C14
  gAg->SetPoint(1, 13.227450, 0.444500); gAg->SetPointError(1, 0., 0.067158); // C13
  gAg->SetPoint(3, 20.107120, 0.412116); gAg->SetPointError(3, 0., 0.040472); // C15
  gAg->SetPoint(4, 18.302800, 0.343888); gAg->SetPointError(4, 0., 0.037580); // C16
  gAg->SetMarkerStyle(20); gAg->SetMarkerSize(1.);
  gAg->SetMarkerColor(kBlack); gAg->SetLineColor(kBlack);
  gAg->SetLineWidth(LW);

  TLegend *lg = new TLegend(0.505,0.65,0.895,0.86);
  // --- sigma_sp from Asia --- //
  // lg->AddEntry(gAysox, "Asia+YSOX", "p");
  // lg->AddEntry(gAwbp, "Asia+WBP", "p");
  // lg->AddEntry(gAnc, "Asia+NCSM", "p");
  // lg->AddEntry(gAg, "Asia+GSM", "p");
  // --- sigma_sp from tos --- //
  lg->AddEntry(gTwbp, "WBP", "p");
  lg->AddEntry(gTnc, "NCSM", "p");
  // lg->AddEntry(gTg, "GSM", "p");
  lg->SetBorderSize(0);

  TCanvas *c = new TCanvas("c", "Rs-DeltaS", 800, 600);
  gHatch->Draw("ApC");
  // the linear fitting //
  TF1 *fTwbp = new TF1("fTwbp", "pol1", -30., 25.);
  fTwbp->SetLineColor(gTwbp->GetLineColor());
  gTwbp->Fit("fTwbp");
  gTwbp->GetFunction("fTwbp")->SetLineStyle(2);
  // TF1 *fTg = new TF1("fTg", "pol1", -30., 25.);
  // fTg->SetLineColor(gTg->GetLineColor());
  // gTg->Fit("fTg");
  // gTg->GetFunction("fTg")->SetLineStyle(2);
  TF1 *fTnc = new TF1("fTnc", "pol1", -30., 25.);
  fTnc->SetLineColor(gTnc->GetLineColor());
  gTnc->Fit("fTnc");
  gTnc->GetFunction("fTnc")->SetLineStyle(2);
  // --- sigma_sp from Asia --- //
  // gAysox->Draw("samep");
  // gAwbp->Draw("samep");
  // gAnc->Draw("samep");
  // gAg->Draw("samep");
  // --- sigma_sp from tos --- //
  gTwbp->Draw("samep");
  gTnc->Draw("samep");
  // gTg->Draw("samep");
  lg->Draw();

  TPaveText *pt = new TPaveText(-5.572597,0.6614069,-3.201504,0.7235211,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  TText *pt_LaTex = pt->AddText("^{12}C");
  pt->Draw();

  pt = new TPaveText(14.07934,0.4824588,16.37006,0.5430941,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{13}C");
  pt->Draw();

  pt = new TPaveText(9.598379-DDS,0.5756301,11.96947-DDS,0.6377443,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{14}C");
  pt->Draw();

  pt = new TPaveText(21.07206,0.4809799,23.40296,0.5430941,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{15}C");
  pt->Draw();

  pt = new TPaveText(19.49143,0.3082248,21.89143,0.3706163,"br");
  pt->SetBorderSize(0);
  pt->SetFillColor(0);
  pt->SetTextColor(2);
  pt->SetTextFont(42);
  pt_LaTex = pt->AddText("^{16}C");
  pt->Draw();


  c->Print("rsCmpHFCp_gn.pdf");
  c->Print("/home/asia/Lab/etfana/cp23/rsCmpHFCp_gn.pdf");
  // c->Print("rsCmp.eps");
} // end the main function
